package com.sytc.camera;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.paint.Paint;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import org.kordamp.bootstrapfx.BootstrapFX;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

import java.io.IOException;

@SpringBootApplication
public class CameraApplication extends Application {

    private ApplicationContext context;

    @Override
    public void init() {
        // 启动 Spring Boot
        context = SpringApplication.run(CameraApplication.class);
    }


    public static void main(String[] args) {
        launch();
    }

    @Override
    public void start(Stage stage) throws IOException {

        // 这一句里的context::getBean参数是关键，有了它，springboot才能控制javafx的类
        FXMLLoader loader = new FXMLLoader(getClass().getResource("/ui/fxml/mainui.fxml"), null, null, context::getBean);

        /*　设置场景　*/
        Scene scene = new Scene(loader.load());
        scene.getStylesheets().add(BootstrapFX.bootstrapFXStylesheet());
        scene.setFill(Paint.valueOf("#5D6263FF")); // 去不掉stage的背景，只好用secene的对pane的圆角中和下


        /* 设置舞台 */
        stage.setScene(scene);
        stage.initStyle(StageStyle.UNDECORATED); // 设置窗口样式为无边框
        stage.setTitle("银心科技");


        /* 显示 */
        stage.show();

    }
}
